<template>
	<view>
		<scroll-view scroll-y class="page">
			<!-- 头部 -->
			<cu-custom bgColor="bg-rgb" :isBack="true">
				<block slot="backText">返回</block>
				<block slot="content">{{title}}</block>
			</cu-custom>
			<!-- 数据列表 -->
			<form @submit="onSubmitPrin">
				<view class="card animation-slide-bottom" :style="[{animationDelay: (0 + 1)*0.1 + 's'}]">
					<view class="cu-form-group">
						<view class="lable">
							物料料号: {{objMsg.materielCode}}
						</view>
					</view>
					<view class="cu-form-group">
						<view class="lable">
							客户料号: {{objMsg.clientCode}}
						</view>
					</view>
					<view class="cu-form-group">
						<view class="lable">
							品名: {{objMsg.materielName}}
						</view>
					</view>
					<view class="cu-form-group">
						<view class="lable">
							规格: {{objMsg.materielGauge}}
						</view>
					</view>
					<view class="cu-form-group">
						<view class="lable">
							单位: {{objMsg.inputUnit}}
						</view>
					</view>
					<view class="cu-form-group">
						<view class="title">退料数量</view>
						<input class="border" :value="objMsg.inputNum" type="number" placeholder="" name="retreatNum"></input>
					</view>
					<view v-if="title === '不合格退料'">
						<view class="cu-form-group">
							<view class="title">实收数量</view>
							<input class="border" :value="objMsg.inputNum" type="number" placeholder="" name="uretreatNum"></input>
						</view>
						<view class="title">退料原因及数量:</view>
						<view class="cu-form-group">
							<view class="title">破损</view>
							<input class="border" type="number" placeholder="" name="reason1"></input>
						</view>
						<view class="cu-form-group">
							<view class="title">断裂</view>
							<input class="border" type="number" placeholder="" name="reason2"></input>
						</view>
						<view class="cu-form-group">
							<view class="title">划伤</view>
							<input class="border" type="number" placeholder="" name="reason3"></input>
						</view>
						<view class="cu-form-group">
							<view class="title">来料损件</view>
							<input class="border" type="number" placeholder="" name="reason4"></input>
						</view>
						<view class="cu-form-group">
							<view class="title">尺寸不符</view>
							<input class="border" type="number" placeholder="" name="reason5"></input>
						</view>
						<view class="cu-form-group">
							<view class="title">功能不良</view>
							<input class="border" type="number" placeholder="" name="reason6"></input>
						</view>
						<view class="cu-form-group">
							<view class="title">实物与焊盘不符</view>
							<input class="border" type="number" placeholder="" name="reason7"></input>
						</view>
						<view class="cu-form-group">
							<view class="title">料号不符</view>
							<input class="border" type="number" placeholder="" name="reason8"></input>
						</view>
						<view class="cu-form-group">
							<view class="title">线束不良</view>
							<input class="border" type="number" placeholder="" name="reason9"></input>
						</view>
						<view class="cu-form-group">
							<view class="title">型号不符</view>
							<input class="border" type="number" placeholder="" name="reason10"></input>
						</view>
						<view class="cu-form-group">
							<view class="title">其它</view>
							<input class="border" type="number" placeholder="" name="reason11"></input>
						</view>
						<view class="cu-form-group">
							<view class="title">备注</view>
							<input class="border" placeholder="" name="remarks"></input>
						</view>
					</view>
				</view>
				<view class="btns">
					<button form-type="submit" class="cu-btn bg-rgb shadow lg">保存</button>
				</view>
			</form>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				objMsg:{},
				title:''
			}
		},
		onLoad() {
			this.objMsg = this.$Route.query.objMsg
			this.title = this.$Route.query.type
			console.log(111,this.objMsg)
		},
		methods:{
			onSubmitPrin(e) {
				let obj = {}
				let url = ''
				if(this.title === '不合格退料'){
					obj = {...e.detail.value}
					obj.materielCode = this.objMsg.materielCode
					obj.clientCode = this.objMsg.clientCode
					obj.materielName = this.objMsg.materielName
					obj.materielSpecs = this.objMsg.materielGauge
					obj.unit = this.objMsg.inputUnit
					obj.perkItemId = this.objMsg.id
					obj.reserveCode = this.objMsg.reserveCode
					obj.state = '0'
					url = 'inspect/materielRetreatRecord/appadd'
				}else{
					obj = {
						returnNum : e.detail.value.retreatNum,
						id : this.objMsg.id
					}
					url = 'storage/mesCertificatePerk/ReturnsInBatches'
				}
				uni.showLoading({
					mask: true,
					title: '保存中.....'
				})
				this.$http.post(url, obj).then(res => {
						uni.hideLoading()
						if(res.data.success){
							this.modal.show({
								type:'success',
								content:'保存成功!'
							})
							uni.navigateBack({
								delta: 1
							})
						}else{
							this.modal.show({
								type:'error',
								content:res.data.message
							})
						}
					})
			}
		}
	}
</script>

<style lang="less">
	.inlinbl {
		display: inline-block;
	}

	.padding-sm {
		padding: 11px 0;
	}

	.borderTop {
		border-top: 0.5px solid #eee;
	}

	.border {
		border: 0.5px solid #eee;
	}

	.cu-form-group {
		padding: 0.5px 0;

		.title {
			height: auto;
			text-align: left;
		}
	}

	.picture-box {
		width: 100%;
		margin-top: 10px;

		.picture {
			width: 100%;
			height: 200px;
			margin-bottom: 10px;
		}
	}

	.card {
		// margin: 30rpx;
		box-shadow: 0px 0px 5rpx 2rpx rgba(0, 0, 0, 0.1);
		border-radius: 10rpx;
		padding: 30rpx;
		margin-bottom: 100rpx;
		background-color: white;
	}

	.card .top {
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-bottom: 1rpx solid #F0F0F0;
		padding-bottom: 20rpx;
		font-weight: bold;
	}

	.top .left {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #485A75;
		line-height: 50rpx;
	}

	.card .bottom .box {
		display: flex;
		justify-content: space-between;
		padding: 20rpx 0;
	}

	.card .bottom .box .lable {
		width: 25%;
	}

	.card .bottom .box .content {
		width: 74%;
		text-align: right;
	}

	.boxs {
		display: flex;
		justify-content: space-between;
		padding: 20rpx 0;
		align-items: center;
	}

	.boxs .title {
		font-weight: bold;
		padding: 10rpx;
		border-radius: 10rpx;
		color: white;
		;
	}

	.boxs input {
		border: 2rpx solid red;
		height: 60rpx;
		padding: 10rpx;
		border-radius: 10rpx;
		font-size: 20rpx;
		color: red;
	}

	.boxs input .input-placeholder {
		color: red;
	}

	uni-textarea {
		border: 2rpx solid #F0F0F0;
		padding: 10rpx;
		border-radius: 10rpx;
		font-size: 20rpx;
	}

	.list {
		margin-bottom: 120rpx;
	}

	.btns {
		position: fixed;
		width: 100%;
		padding: 0 16px;
		z-index: 999;
		background: white;
		bottom: 0;
		height: 100rpx;
		line-height: 100rpx;
	}

	.cu-btn {
		width: 100%;
		// margin-left: 50rpx;
	}
</style>
